<template>
  <div>
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane v-if="showDraftTabs" label="草稿库" name="draft">
        <Draft v-if="activeName === 'draft'" ref="draft"/>
      </el-tab-pane>

      <el-tab-pane v-if="showOfficialTabs" :showStatus="this.isShow" label="正式库" name="official">
        <Official v-if="activeName === 'official'" ref="official"/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import Draft from "@/components/exerciseBook/Draft"
  import Official from "./Official"

  export default {
    name: "ExerciseIndex",
    components: {
      Draft, Official
    },
    data() {
      return {
        activeName: 'draft',
        showDraftTabs: true,
        showOfficialTabs: true,
        showPushTabs: true,
        isShow:''
      };
    },
    methods: {
    },
    created() {
      if (this.$store.state.user.userName === 'admin') {
        return
      }
      //角色Id等于管理员角色
      for (let i = 0; i < this.$store.state.user.roleIds.length; i++) {
        if (this.$store.state.user.roleIds[i] === '1455781731549327361') {
          return;
        }
      }
      UTIL.findTreeNode(this.$store.state.menuList, item => {
        if (item.id === this.$store.state.activeId) {
          if (item.editButton || item.detailButton) {
            if (item.editButton && item.detailButton) {
              this.activeName = 'draft'
              this.isShow = 'false'
            } else {
              if (item.detailButton) {
                this.showDraftTabs = false
                this.activeName = 'official'
                this.isShow = "true"
              }
            }
          }
          if (item.editButton && item.pushButton) {
            this.showDraftTabs = true
            this.showOfficialTabs = true
          } else {
            if (item.detailButton && item.pushButton) {
              this.showDraftTabs = false
              this.showOfficialTabs = true
              this.activeName = 'official'
            }
          }
        }
      })
    }
  }
</script>

<style scoped>

</style>
